//package com.gk.study.service.impl;
//
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.gk.study.entity.Comment;
//import com.gk.study.mapper.CommentMapper;
//import com.gk.study.service.CommentService;
//import org.apache.ibatis.annotations.Param;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.time.LocalDateTime;
//import java.util.List;
//
//@Service
//public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {
//    @Autowired
//    CommentMapper mapper;
//
//    @Override
//    public List<Comment> getCommentList() {
//        return mapper.getList();
//    }
//
//    @Override
//    public void createComment(Comment comment) {
//        comment.setCommentTime(LocalDateTime.now());
//        mapper.insert(comment);
//    }
//
//    @Override
//    public void deleteComment(String id) {
//        mapper.deleteById(id);
//    }
//
//    @Override
//    public void updateComment(Comment comment) {
//        mapper.updateById(comment);
//    }
//
//    @Override
//    public Comment getCommentDetail(String id) {
//        return mapper.selectById(id);
//    }
//
//    @Override
//    public List<Comment> getThingCommentList( String thingId, String order) {
//        return mapper.selectThingCommentList(thingId, order);
//    }
//
//    @Override
//    public List<Comment> getUserCommentList(String userId) {
//        return mapper.selectUserCommentList(userId);
//    }
//}
package com.gk.study.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gk.study.entity.Comment;
import com.gk.study.mapper.CommentMapper;
import com.gk.study.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {
    @Autowired
    CommentMapper mapper;

    @Override
    public List<Comment> getCommentList() {
        return mapper.getList();
    }

    @Override
    public void createComment(Comment comment) {
        comment.setCommentTime(LocalDateTime.now());
        mapper.insert(comment);
    }

    @Override
    public void deleteComment(String id) {
        mapper.deleteById(id);
    }

    @Override
    public void updateComment(Comment comment) {
        mapper.updateById(comment);
    }

    @Override
    public Comment getCommentDetail(String id) {
        return mapper.selectById(id);
    }

    @Override
    public List<Comment> getThingCommentList(String thingId, String order) {
        return mapper.selectThingCommentList(thingId, order);
    }

    @Override
    public List<Comment> getUserCommentList(String userId) {
        return mapper.selectUserCommentList(userId);
    }
}
